package com.ruoyi.voucher.controller;

import com.ruoyi.voucher.domain.Voucher;
import com.ruoyi.voucher.service.IVoucherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;

/**
 * @author:cocoKe
 * @Description:
 * @VERSON:1.8
 * @create:2025-03-01 09:31
 * @Date:2025/3/1
 */
@RestController
@RequestMapping("/voucher")
public class VoucherController {



    @Autowired
    IVoucherService voucherService;

    /**
     * 导出数据
     *
     * @return
     */
    @PostMapping("/export")
    public void export(HttpServletResponse response, Voucher voucher)
    {
        // TODO， 查询所有数据，并导出到Excel文件中
        voucherService.export(response, voucher);
    }

    /*
     * 导入数据
     */
    @PostMapping("/import")
    public void importData(@RequestPart("file") MultipartFile file) throws Exception {
        // TODO， 导入Excel文件中的数据到数据库中
        voucherService.importData(file);
    }


}
